﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Modules/MasterPage/Main_Master.Master" AutoEventWireup="true" CodeBehind="Staff.aspx.cs" Inherits="ERB.Modules.CRM.Staff" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpBreadcrumb" runat="server">
        <uc:Breadcrumb ID="ucBreadcrumb" runat="server" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cpMainContent" runat="server">
    <script type="text/javascript">
        function New() {
            popupPotential.Show();
            cpLoadData.PerformCallback();
            $("#hfAction").val("Insert");
        }

        function Edit_Data(s, e) {
            var id = AspxGV1.GetRowKey(AspxGV1.GetFocusedRowIndex());
            popupPotential.Show();
            cpLoadData.PerformCallback();
            cpLoadData.PerformCallback('LoadDataEdit;' + id);
            $("#hfAction").val("Update");
            $("#hfID").val(id);
        }
        function Save() {
            var action = $("#hfAction").val();
            if (action == "Insert") {
                cpReloadGrid.PerformCallback('Insert');
            } else if (action == "Update") {
                cpReloadGrid.PerformCallback('Update');
            }
        }

        function SaveComplete(s, e) {
            var check = e.result;
            if (check == "Success") {
                popupPotential.Hide();
                LoadGrid.PerformCallback();
                $("#hfAction").val("");
            } else if (check == "SuccessAndNew") {
                New();
            }
        }

        function SaveNew() {
            cpReloadGrid.PerformCallback('SaveNew');
        }
        function Exit() {
            popupPotential.Hide();
            LoadGrid.PerformCallback();
        }
        function LoadDistrict() {
            ReloadCbbDistrict.PerformCallback();
        }
        function LoadShipDistrict() {
            ReloadCbbShipDistrict.PerformCallback();
        }
    </script>
    <asp:HiddenField ID="hfID" ClientIDMode="Static" runat="server" />
    <asp:HiddenField ID="hfAction" ClientIDMode="Static" runat="server" />
    <uc:NavControl ID="NavControl" runat="server" nodecurrenttext="<%$ Resources:Language , StaffCurrentText %>"
        nodecurrenturl="../../Modules/Master_Data/Staff.aspx" noderoottext="<%$ Resources:Language , StaffRootText %>"
        addnewscript="function(s, e){New(); }" editscript="function (s, e){Edit_Data(s,e); }" />
    <div class="contentMain">
        <dx:ASPxCallbackPanel ID="LoadGrid" ClientInstanceName="LoadGrid" runat="server"
            OnCallback="LoadGrid_Callback">
            <PanelCollection>
                <dx:PanelContent>
                    <dx:ASPxGridView ID="ASPxGridView1" runat="server" ClientInstanceName="AspxGV1" SkinID="Default"
                        AutoGenerateColumns="False" KeyFieldName="Salesperson" DataSourceID="dsCustomer"
                        OnCustomCallback="ASPxGridView1_CustomCallback">
                        <Columns>
                            <dx:GridViewCommandColumn ShowSelectCheckbox="True" Width="35px" ButtonType="Image">
                                <HeaderTemplate>
                                    <dx:ASPxCheckBox ID="ASPxCheckBox1" runat="server" ToolTip="Check All"
                                        CssPostfix="Aqua" CssFilePath="~/App_Themes/Aqua/{0}/styles.css">
                                        <ClientSideEvents CheckedChanged="function(s, e) {
	AspxGV1.SelectAllRowsOnPage(s.GetChecked());}" />
                                    </dx:ASPxCheckBox>
                                </HeaderTemplate>
                            </dx:GridViewCommandColumn>
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffNameMaster %>" FieldName="SalespersonName" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffTitleMaster %>" FieldName="SalSalespersonNameCat" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffMobileMaster %>" FieldName="HandPhone" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffHomePhoneMaster %>" FieldName="HomePhone" Width="130px" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffEmailMaster %>" FieldName="Email" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffAssressMaster %>" FieldName="Address" />
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffBirthdayMaster %>" FieldName="Birthday">
                                <PropertiesTextEdit DisplayFormatString="{0:dd/MM/yyyy}">
                                </PropertiesTextEdit>
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffHireDateMaster %>" FieldName="Hiredate">
                                <PropertiesTextEdit DisplayFormatString="{0:dd/MM/yyyy}">
                                </PropertiesTextEdit>
                            </dx:GridViewDataTextColumn>
                            <dx:GridViewDataTextColumn Caption="<%$ Resources:Language , StaffReportToMaster %>" FieldName="ReportName" />
                        </Columns>
                        <SettingsBehavior ColumnResizeMode="Control" />
                        <Settings ShowFilterRow="True"></Settings>
                    </dx:ASPxGridView>
                </dx:PanelContent>
            </PanelCollection>
        </dx:ASPxCallbackPanel>
        <asp:SqlDataSource ID="dsCustomer" runat="server" ConnectionString="<%$ ConnectionStrings:ChiThanhCo_ConnectionString %>"
            SelectCommand="SalSalesperson_Salespersion" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
    </div>
    <dx:ASPxPopupControl ID="popupPotential" runat="server" ClientIDMode="AutoID" Height="600px"
        Theme="PlasticBlue" Width="1000px" ClientInstanceName="popupPotential" HeaderText="<%$ Resources:Language , StaffCurrentText %>"
        PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" EnableClientSideAPI="True"
        PopupAction="None" PopupElementID="divPotential" CloseAction="CloseButton" AllowDragging="True">
        <ContentStyle>
            <Paddings Padding="2px" />
            <Paddings Padding="2px"></Paddings>
        </ContentStyle>
        <ContentCollection>
            <dx:PopupControlContentControl ID="PopupControlContentControl1" runat="server" SupportsDisabledAttribute="True">
                <div class="NavButtonRight">
                    <dx:ASPxButton ID="btnsave" ClientInstanceName="btnsave" UseSubmitBehavior="false"
                        AutoPostBack="false" runat="server" Text="<%$ Resources:Language , btnSave %>" CssClass="button" ValidationGroup="editForm">
                        <ClientSideEvents Click="function(s, e){Save();}" />
                    </dx:ASPxButton>
                    &nbsp;
                    <dx:ASPxButton ID="btnsaveadd" runat="server" ClientInstanceName="btnsaveadd" Text="<%$ Resources:Language , btnSaveNew %>"
                        UseSubmitBehavior="false" AutoPostBack="false" CssClass="button" ValidationGroup="editForm">
                        <ClientSideEvents Click="function(s, e){SaveNew();}" />
                    </dx:ASPxButton>
                    &nbsp;
                    <dx:ASPxButton ID="btnExit" runat="server" Text="<%$ Resources:Language , btnExit %>" CssClass="button" ClientInstanceName="btnExit"
                        UseSubmitBehavior="false" AutoPostBack="false">
                        <ClientSideEvents Click="function(s, e){Exit();}" />
                    </dx:ASPxButton>
                </div>
                <div>
                    <dx:ASPxCallbackPanel ID="cpLoadData" runat="server" ClientInstanceName="cpLoadData"
                        OnCallback="cpLoadData_Callback">
                        <ClientSideEvents EndCallback="function(s, e){SaveComplete();}" />
                        <PanelCollection>
                            <dx:PanelContent ID="PanelContent1" runat="server">
                                <table cellpadding="0" cellspacing="0" class="table_edit" width="100%">
                                    <tbody>
                                        <tr>
                                            <td>
                                                <table cellpadding="2" cellspacing="2" class="style1" width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:Panel ID="Panel_Address" runat="server" CssClass="ColapsePanel">
                                                                <dx:ASPxLabel ID="Label11" runat="server" Text="<%$ Resources:Language , StaffInfomation %>">
                                                                </dx:ASPxLabel>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style3" valign="top">
                                                <table cellpadding="0" cellspacing="0" class="tblFormView" width="100%">
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel7" runat="server" Text="<%$ Resources:Language , StaffCode %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtStaffID" runat="server" Width="90%" TabIndex="1" SkinID="requireField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label12" runat="server" Text="<%$ Resources:Language , StaffFullname %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtStaffName" runat="server" Width="90%" TabIndex="2" SkinID="requireField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label15" runat="server" Text="<%$ Resources:Language , StaffReportTo %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxComboBox ID="cboReportTo" runat="server" Width="90%" DataSourceID="dsReportTo"
                                                                TextField="SalespersonName" ValueField="Salesperson" TabIndex="3">
                                                            </dx:ASPxComboBox>
                                                            <asp:SqlDataSource ID="dsReportTo" runat="server" ConnectionString="<%$ ConnectionStrings:ChiThanhCo_ConnectionString %>"
                                                                SelectCommand="SalSalesperson_Salespersion" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="Label16" runat="server" Text="<%$ Resources:Language , StaffTitle %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxComboBox ID="cboSalesPersonCat" runat="server" Width="90%" DataSourceID="dsHighStaff"
                                                                TextField="Description" ValueField="SalespersonCat" TabIndex="3" SkinID="cmbrequireField">
                                                            </dx:ASPxComboBox>
                                                            <asp:SqlDataSource ID="dsHighStaff" runat="server" ConnectionString="<%$ ConnectionStrings:ChiThanhCo_ConnectionString %>"
                                                                SelectCommand="SalSalespersonCat_SalespersonCat" SelectCommandType="StoredProcedure"></asp:SqlDataSource>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel8" runat="server" Text="<%$ Resources:Language , StaffResign %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxCheckBox ID="ChkOnholdStaff" TabIndex="5" runat="server">
                                                            </dx:ASPxCheckBox>
                                                        </td>
                                                        <td></td>
                                                        <td></td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <table cellpadding="2" class="style1" width="100%">
                                                    <tr>
                                                        <td>
                                                            <asp:Panel ID="Panel1" runat="server" CssClass="ColapsePanel">
                                                                <dx:ASPxLabel ID="Label2" runat="server" Text="<%$ Resources:Language , StaffContact %>">
                                                                </dx:ASPxLabel>
                                                            </asp:Panel>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="style3" valign="top">
                                                <table cellpadding="0" cellspacing="0" class="tblFormView" width="100%">
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel1" runat="server" Text="<%$ Resources:Language , StaffAddress %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtAddressStaff" runat="server" Width="90%" TabIndex="6" SkinID="requireField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel2" runat="server" Text="<%$ Resources:Language , StaffEmail %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxTextBox ID="txtEmailStaff" runat="server" Width="90%" TabIndex="7" SkinID="emailField">
                                                            </dx:ASPxTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel3" runat="server" Text="<%$ Resources:Language , StaffPhone %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtPhoneStaff" TabIndex="8" runat="server" Width="90%" SpinButtons-ShowIncrementButtons="false" MaxLength="12">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel4" runat="server" Text="<%$ Resources:Language , StaffBirthDay %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxDateEdit ID="txtBirthdateStaff" runat="server" TabIndex="9" Width="90%" EditFormatString="dd/MM/yyyy">
                                                            </dx:ASPxDateEdit>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel5" runat="server" Text="<%$ Resources:Language , StaffHandPhone %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxSpinEdit ID="txtHandPhoneStaff" TabIndex="10" runat="server" Width="90%" SpinButtons-ShowIncrementButtons="false" MaxLength="15">
                                                            </dx:ASPxSpinEdit>
                                                        </td>
                                                        <td class="tblFormViewtdLabel">
                                                            <dx:ASPxLabel ID="ASPxLabel6" runat="server" Text="<%$ Resources:Language , StaffHireDate %>">
                                                            </dx:ASPxLabel>
                                                        </td>
                                                        <td class="tblFormViewtdValue">
                                                            <dx:ASPxDateEdit ID="txtDateStartWork" TabIndex="11" runat="server" Width="90%" EditFormatString="dd/MM/yyyy" SkinID="daterequire">
                                                            </dx:ASPxDateEdit>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>
                            </dx:PanelContent>
                        </PanelCollection>
                    </dx:ASPxCallbackPanel>
                </div>
            </dx:PopupControlContentControl>
        </ContentCollection>
    </dx:ASPxPopupControl>
    <dx:ASPxCallback ID="cpReloadGrid" ClientInstanceName="cpReloadGrid" runat="server"
        OnCallback="cpReloadGrid_Callback">
        <ClientSideEvents CallbackComplete="function(s,e){SaveComplete(s,e);}" />
    </dx:ASPxCallback>
</asp:Content>
